import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/modules/account/page/account_withdraw_history_info/view.dart';
import 'package:honeypotflutter/public/public_get.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/public/public_date.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_card.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_item.dart';
import '../model/account_withdraw_history_model.dart';

class AccountWithdrawHistoryItem extends StatelessWidget {
  final AccountWithdrawHistoryItemModel itemModel;

  const AccountWithdrawHistoryItem({
    super.key,
    required this.itemModel,
  });

  /*
  * 获取状态
  * */
  String getStatusTitle() {
    if (itemModel.state == null) {
      return "";
    }
    String title = "";
    if (itemModel.state == 5) {
      title = "提现成功";
    } else if (itemModel.state == 1) {
      title = "审核中";
    } else if (itemModel.state == 2) {
      title = "审核中";
    } else {
      title = "提现失败(已退回)";
    }
    return title;
  }

  /*
  * 获取状态颜色
  * */
  Color getStatusColor() {
    if (itemModel.state == null) {
      return MGColors.text1Color;
    }
    Color color;
    print("ssssss${itemModel.state}");
    if (itemModel.state == 5) {
      color = MGColors.greenColor;
    } else if (itemModel.state == 1) {
      color = MGColors.blueColor;
    } else if (itemModel.state == 2) {
      color = MGColors.blueColor;
    } else {
      color = MGColors.redColor;
    }
    return color;
  }

  @override
  Widget build(BuildContext context) {
    return MGCard(
      children: [
        MGItems(
          padding: EdgeInsets.only(bottom: 2),
          leadTitle: itemModel.watWithdrawPayTypeDisplayName,
          leadStyle: TextStyle(
            fontSize: MGFont.textFont2,
            color: MGColors.text1Color,
            fontWeight: FontWeight.bold,
          ),
          trailingTitle: "-${itemModel.amount?.toStringAsFixed(2)}元",
          trailingStyle: TextStyle(
            fontSize: MGFont.textFont2,
            color: MGColors.text1Color,
            fontWeight: FontWeight.bold,
          ),
        ),
        MGItems(
            padding: EdgeInsets.only(top: 2, bottom: 15),
            leadTitle: HLDate.hl_formatDate(itemModel.createTime),
            leadStyle: TextStyle(
              fontSize: MGFont.textFont2,
              color: MGColors.text3Color,
            ),
            trailingTitle: getStatusTitle(),
            trailingStyle: TextStyle(
              fontSize: MGFont.textFont2,
              color: getStatusColor(),
            ))
      ],
      action: () {
        HLGet.to(AccountWithdrawHistoryInfoPage(), arguments: itemModel);
      },
    );
  }
}
